package s47.dqj.dao;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import s47.dqj.bean.DoctorMethodDetail;

/**
 * 22.处方清单表
 * @author Administrator
 *
 */
@Repository("doctorMethodDetailDaoImpl")
public class DoctorMethodDetailDaoImpl extends HibernateDaoSupport implements DoctorMethodDetailDaoInf{
	
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DoctorMethodDetailDaoInf#setSupperSessionFactory(org.hibernate.SessionFactory)
	 */
	@Override
	@Resource(name="sessionFactory")
	public void setSupperSessionFactory(SessionFactory sessionFactory){
		super.setSessionFactory(sessionFactory);
	}
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DoctorMethodDetailDaoInf#findAllByDmid(s47.dqj.bean.DoctorMethodDetail)
	 */
	@Override
	public List<DoctorMethodDetail> findAllByDmid(DoctorMethodDetail doctorMethodDetail){
		String hql="from DoctorMethodDetail as dmd where dmd.dmid.dmid=:dmid";
		Query query=getSession().createQuery(hql);
		query.setInteger("dmid", doctorMethodDetail.getDmid().getDmid());
		return query.list();
	}
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DoctorMethodDetailDaoInf#findAllByMiid(s47.dqj.bean.DoctorMethodDetail)
	 */
	@Override
	public List<DoctorMethodDetail> findAllByMiid (DoctorMethodDetail doctorMethodDetail){
		String hql="from DoctorMethodDetail as dmd where dmd.miid.miid=:miid";
		Query query=getSession().createQuery(hql);
		query.setInteger("miid", doctorMethodDetail.getMiid().getMiid());
		return query.list();
	}
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DoctorMethodDetailDaoInf#save(s47.dqj.bean.DoctorMethodDetail)
	 */
	@Override
	public void save(DoctorMethodDetail doctorMethodDetail){
		getHibernateTemplate().save(doctorMethodDetail);
	}
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DoctorMethodDetailDaoInf#update(s47.dqj.bean.DoctorMethodDetail)
	 */
	@Override
	public void update(DoctorMethodDetail doctorMethodDetail){
		getHibernateTemplate().update(doctorMethodDetail);
	}
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DoctorMethodDetailDaoInf#delete(s47.dqj.bean.DoctorMethodDetail)
	 */
	@Override
	public void delete(DoctorMethodDetail doctorMethodDetail){
		getHibernateTemplate().delete(doctorMethodDetail);
	}
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DoctorMethodDetailDaoInf#findObject(s47.dqj.bean.DoctorMethodDetail)
	 */
	@Override
	public DoctorMethodDetail findObject(DoctorMethodDetail doctorMethodDetail){
		return getHibernateTemplate().get(DoctorMethodDetail.class, doctorMethodDetail.getDmdid());
	}
	 
}